import numpy as np
import os
import shutil
fileNames = ['DD','MUTAG','NCI1']
for fileName in fileNames:
    for i in range(1,17):
        source_path = os.path.abspath(r'D:\MasterStudents\2020\ChenXin\GDVshuffleTest\\' + fileName)
        target_path = os.path.abspath(r'D:\MasterStudents\2020\ChenXin\GDVshuffleTest\\' + fileName + ' shuffle' + str(i))

        if not os.path.exists(target_path):
            # 如果目标路径不存在原文件夹的话就创建
            os.makedirs(target_path)

        if os.path.exists(source_path):
            # 如果目标路径存在原文件夹的话就先删除
            shutil.rmtree(target_path)

        shutil.copytree(source_path, target_path)
        with  open(fileName+".out") as f:
            buff = []
            lines =  f.readlines()
            for line in lines:
                buf = np.array(line.strip().split()).astype(np.int)
                np.random.shuffle(buf)
                buff.append(buf.tolist())
            buff = np.array(buff)
            np.savetxt(r'D:\MasterStudents\2020\ChenXin\GDVshuffleTest\\' + fileName+' shuffle'+ str(i)+'\\'+fileName+'_node_attributes.txt',buff,fmt='%d')

